<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>成员列表</title>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"
          name="viewport"/>
    <link href="../layui/css/layui.css" rel="stylesheet">
    <script src="../layui/layui.js" type="text/javascript"></script>
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
    <link href="../ladmin/lib/layui/css/modules/layer/default/layer.css" rel="stylesheet" type="text/css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<table class="layui-hide" id="followTable" lay-filter="followTable" style="width: 100%"></table>


<script id="toolbar" type="text/html">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="addMember">添加成员</button>
    </div>
</script>

<script id="barDemo" type="text/html">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="restPassword">重置密码</button>
    </div>
</script>


<script type="text/javascript">

    layui.use('table', function () {


        var table = layui.table;
        table.render({
            elem: "#followTable",
            skin: 'line',
            url: 'getMemberList',
            toolbar: '#toolbar',
            method:'Post',
            cols: [
                [
                {field: "id", title: "学号", align: 'center'},
                {field: "name", title: "姓名", align: 'center'},
                {field: "major", title: "班级", align: 'left'},
                {field: "birthday", title: "生日", align: 'center', sort: true},
                {field: "address", title: "地址", align: 'left'},
                {field: "phone", title: "联系方式", align: 'center'},
                {field: "qq", title: "QQ", align: 'center'},
                {field: "weChat", title: "微信", align: 'left'},
                {field: "email", title: "邮箱", align: 'center'},
                {field: "tool", title: "操作", align: 'center', toolbar: '#barDemo'}
            ]
            ],

            done: function (res, curr, count) {
                table = res.data;
            },
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['prev', 'page', 'next', 'skip'] //自定义分页布局
                , groups: 3 //只显示 1 个连续页码
                , first: true //不显示首页
                , last: true//不显示尾页

            }

        });

        table.on('tool(followTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'restPassword') {
                var id = {id: data.id};
                $.ajax({

                    type: 'POST',
                    url: 'restPassword',
                    async: true,
                    traditional: true,
                    data: JSON.stringify(id),
                    dataType: 'Text',
                    contentType: "application/json;charset=UTF-8",
                    success: function (data2) {
                        layer.msg(data.id + data.name + '密码重置成功');

                    }

                });

            }


        });
        table.on('toolbar(followTable)', function (obj) {
            if (obj.event == "addMember") {
                layer.open({
                    type: 2,
                    title: '添加成员',
                    maxmin: true,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['800px', '520px'],
                    content: 'addMember',
                    end: function () {
                        location.reload();
                    }
                })
            }

        });


    })


</script>
</body>
</html>